<template>
	<jk-dialog
		v-model="showDialog"
		title="详情-质量模版"
		width="800px"
		:show-content-loading="showLoading"
		append-to-body
		:show-close-btn="true"
		:show-confirm-btn="false"
		:show-cancel-btn="false"
		@on-close="onVisibleChange(false)"
		@on-visible-change="onVisibleChange"
	>
		<el-form ref="ruleForm" :model="ruleForm" label-width="110px" :show-message="false">
			<el-row ref="box1">
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="模版名称">
						<jk-input v-model="ruleForm.name" disabled class="width-100-percent" placeholder="模版名称"></jk-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="检验类型">
						<el-select v-model="ruleForm.typeName" disabled class="width-100-percent" placeholder="检验类型">
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="排序">
						<jk-number-input v-model="ruleForm.sortNum" disabled class="width-100-percent"></jk-number-input>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<jk-table border :data="ruleForm.itemList" :height="dialogTableHeight - 20">
			<vxe-column title="操作" align="center" field="processName" :width="120">
				<template slot="header">
					<el-button type="text" size="mini" disabled>添加</el-button>
				</template>
				<template slot-scope="scope">
					<div class="flex-center">
						<jk-button type="default" class="item-gap" icon="el-icon-plus" size="mini" disabled></jk-button>
						<jk-button type="default" icon="el-icon-minus" size="mini" disabled></jk-button>
					</div>
				</template>
			</vxe-column>
			<vxe-column title="序号" type="seq" align="center" :width="80"> </vxe-column>
			<vxe-column title="指标" align="left" field="processId" :width="160">
				<template slot-scope="scope">
					<span>{{ scope.row.qualityItemName }}</span>
				</template>
			</vxe-column>
		</jk-table>
	</jk-dialog>
</template>

<script>
    import calHeight from '/src/mixins/cal-dialog-height';
    import { spinWorkshopAreaGet } from '../../../api/basicData/workshopArea';
    import { spinQualityInspectionModelGet } from '../../../api/quality/processQuality';
    export default {
        name: 'WorkshopArea',
        props: {
            dialogState: {
                type: Boolean,
                default: false
            },
            dataId: {
                type: [String, Number],
                default: ''
            }
        },
        mixins: [calHeight],
        data() {
            return {
                showDialog: false,
                showLoading: true,
                ruleForm: {}
            };
        },
        methods: {
            onVisibleChange(e) {
                this.$emit('on-visible-change', e);
                if (!e) {
                    Object.assign(this.$data, this.$options.data());
                    this.$nextTick(() => {
                        this.$refs.ruleForm.resetFields();
                    });
                }
            },
            getDetailRequest() {
                this.showLoading = true;
                return spinQualityInspectionModelGet({ id: this.dataId }).then(res => {
                    this.showLoading = false;
                    if (res.data.status === 200) {
                        this.ruleForm = res.data.res;
                    }
                });
            }
        },
        watch: {
            dialogState(newVal) {
                this.showDialog = newVal;
                if (newVal) {
                    this.getDetailRequest();
                }
            }
        }
    };
</script>
